<style>
  .ivu-input{
    height: 35px;
  }
  textarea.ivu-input{
    resize:none;
    height: 100px
  }
</style>
<template>
  <div class="qualityTreatment">
    <div class="sta_title">
      <div class="goBack" @click="save">
        <Icon type="ios-arrow-back"/>
        <span class="gb_font">返回</span></div>
      <div class="st_font">
        <span class="stf_title">{{name}}手动添加</span>
      </div>
    </div>
    <div class="content">
      <div class="con">
        <span class="title">产品编码</span>
        <Input v-model="productCode" placeholder="请输入产品编码" />
      </div>
      <div class="con">
        <span class="title">选择原因</span>
        <Select v-model="reason" style="width:200px">
          <Option v-for="item in reasonLists" :value="item.parameter_id" :key="item.parameter_id">{{ item.name }}</Option>
        </Select>
      </div>
      <div class="con">
        <span class="title">备注</span>
        <Input v-model="notes" type="textarea" placeholder="请填写备注" />
      </div>
    </div>
  </div>
</template>

<script>
  import cookie from 'js-cookie';
  export default {
    name: "addQuality",
    props: ['quesId','type','name'],
    data() {
      return {
        productCode: '',
        reasonLists: [],
        reason: '',
        notes: ''
      }
    },
    created() {
      this.getInfo()
    },
    methods: {
      save() {
        let self = this
        this.$Loading.start();
        var str = {
          problem_id: self.quesId,
          type: self.type,
          item_num: self.productCode,
          parameter_id: self.reason,
          notes: self.notes,
          uid: cookie.get('uid'),
          loginType: cookie.get('loginType')
        };
        var strdata = this.$twjsdes.enstr(str);
        this.$http.post(this.$API_URL + '/item/qualityadd', {alldata: strdata.alldata}).then((response) => {
          var res = this.$twjsdes.decrypt(response.data.alldata);
          this.$emit('saveAdd', res.data.cont)
          this.$Loading.finish();
        }).catch(function (error) {
          this.$Modal.error({
            title: '提示',
            content: '网络连接错误，请检查后重试'
          });
          console.log(error);
        });
      },
      getInfo(){
        let self = this
        this.$Loading.start();
        var str = {
          problem_id: self.quesId,
          uid: cookie.get('uid'),
          loginType: cookie.get('loginType')
        };
        var strdata = this.$twjsdes.enstr(str);
        this.$http.post(this.$API_URL + '/item/qualityaddchoice', {alldata: strdata.alldata}).then((response) => {
          var res = this.$twjsdes.decrypt(response.data.alldata);
          self.reasonLists = res.data.list
          this.$Loading.finish();
        }).catch(function (error) {
          this.$Modal.error({
            title: '提示',
            content: '网络连接错误，请检查后重试'
          });
          console.log(error);
        });
      },
    }
  }
</script>

<style scoped lang="less">
  .qualityTreatment {
    width: 79%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: fixed;
    right: 0;
    top: 0;
    opacity: 10;
    background: #f4f4f4;
    padding: 0 16px;
    box-sizing: border-box;
    .sta_title {
      display: flex;
      flex-direction: row;
      justify-content: center;
      position: relative;
      margin: 16px 0;
      width: 100%;
      height: 36px;
      line-height: 36px;
      .goBack {
        display: flex;
        flex-direction: row;
        position: absolute;
        left: 0;
        top: 0;
        cursor: pointer;
        .ivu-icon {
          font-size: 20px;
          line-height: 36px;
        }
        .gb_font {
          font-size: 17px;
          color: #666666;
          line-height: 37px;
        }
      }
      .st_font {
        display: flex;
        flex-direction: row;
        .stf_title {
          font-size: 17px;
          color: #222222;
          margin-left: 50px;
          margin-right: 50px;
        }
      }
    }
    .content{
      width: 100%;
      background: #fff;
      border-radius: 5px;
      border: 1px solid #e1e1e1;
      display: flex;
      flex-direction: column;
      padding: 0 16px;
      box-sizing: border-box;
      .con{
        display: flex;
        flex-direction: column;
        padding-bottom: 20px;
        border-bottom: 1px dashed #e5e5e5;
        .title{
          font-size: 13px;
          color: #666666;
          line-height: 13px;
          margin-top: 16px;
          margin-bottom: 10px;
        }
      }
      .con:last-child{
        border-bottom: none;
      }
    }
  }
  /* 手机竖屏 */
  @media screen and (min-width: 0px) and (max-width: 820px) {
    .qualityTreatment{
      width: 100%;
      padding: 0 8px;
      .sta_title{
        margin: 8px 0;
      }
      .content{
        padding: 0 8px;
        .con{
          padding: 8px 0;
          .title{
            margin-top: 8px;
            margin-bottom: 5px;
          }
        }
      }
    }
  }
</style>